package com.sihai.ehr.web.listener;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

public class UserSessionListener implements HttpSessionBindingListener {

    private Long userid;

	public UserSessionListener(Long userid) {
		this.userid = userid;
	}

    @Override
    public void valueBound(HttpSessionBindingEvent event) {
        this.onLogin(event.getSession());
    }

    @Override
    public void valueUnbound(HttpSessionBindingEvent event) {
        this.onLogout(event.getSession());
    }

    //作登录日志
    private void onLogin(final HttpSession session) {
        /*OperationLogMessage log = new OperationLogMessage();
        log.setOperator(userid);
        log.setOperate("登录");

        MessageBus bus = BeanLocator.getBean(MessageBus.class);
        bus.dispatch(log);*/
    }

    //作登出日志
    private void onLogout(final HttpSession session) {
        /*OperationLogMessage log = new OperationLogMessage();
        log.setOperator(userid);
        log.setOperate("登出");

        MessageBus bus = BeanLocator.getBean(MessageBus.class);
        bus.dispatch(log);*/
    }

}
